﻿/***********************************************************************************************************************************
 *    Name: Set-BackupDirectory.sql
 *  Author: Frank Figearo — http://www.sqlnerd.me/ — frank@sqlnerd.me
 * Summary: 
**/
DECLARE @Value NVARCHAR(255);
SET @Value= N'\\DC1-vp-DR4300\SQL_Prod\' + REPLACE(CAST(SERVERPROPERTY('ServerName') AS NVARCHAR(128)), N'\', N'-');
PRINT @Value;
EXECUTE dbo.xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'BackupDirectory', N'REG_SZ', @Value;
EXECUTE DBAdmin.BackupDBs N'$';
GO